/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package smartgrid;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;

import java.io.Serializable;
public class SemanaAgregada implements Serializable {
	public SemanaAgregada() {
	}
	
	public static SemanaAgregada loadSemanaAgregadaByORMID(int ID) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return loadSemanaAgregadaByORMID(session, ID);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada getSemanaAgregadaByORMID(int ID) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return getSemanaAgregadaByORMID(session, ID);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada loadSemanaAgregadaByORMID(int ID, org.hibernate.LockMode lockMode) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return loadSemanaAgregadaByORMID(session, ID, lockMode);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada getSemanaAgregadaByORMID(int ID, org.hibernate.LockMode lockMode) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return getSemanaAgregadaByORMID(session, ID, lockMode);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada loadSemanaAgregadaByORMID(PersistentSession session, int ID) {
		try {
			return (SemanaAgregada) session.load(smartgrid.SemanaAgregada.class, new Integer(ID));
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada getSemanaAgregadaByORMID(PersistentSession session, int ID) {
		try {
			return (SemanaAgregada) session.get(smartgrid.SemanaAgregada.class, new Integer(ID));
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada loadSemanaAgregadaByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) {
		try {
			return (SemanaAgregada) session.load(smartgrid.SemanaAgregada.class, new Integer(ID), lockMode);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada getSemanaAgregadaByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode) {
		try {
			return (SemanaAgregada) session.get(smartgrid.SemanaAgregada.class, new Integer(ID), lockMode);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada[] listSemanaAgregadaByQuery(String condition, String orderBy) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return listSemanaAgregadaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada[] listSemanaAgregadaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return listSemanaAgregadaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada[] listSemanaAgregadaByQuery(PersistentSession session, String condition, String orderBy) {
		StringBuffer sb = new StringBuffer("From smartgrid.SemanaAgregada as SemanaAgregada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (SemanaAgregada[]) list.toArray(new SemanaAgregada[list.size()]);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada[] listSemanaAgregadaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) {
		StringBuffer sb = new StringBuffer("From smartgrid.SemanaAgregada as SemanaAgregada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (SemanaAgregada[]) list.toArray(new SemanaAgregada[list.size()]);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada loadSemanaAgregadaByQuery(String condition, String orderBy) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return loadSemanaAgregadaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada loadSemanaAgregadaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return loadSemanaAgregadaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada loadSemanaAgregadaByQuery(PersistentSession session, String condition, String orderBy) {
		SemanaAgregada[] semanaAgregadas = listSemanaAgregadaByQuery(session, condition, orderBy);
		if (semanaAgregadas != null && semanaAgregadas.length > 0)
			return semanaAgregadas[0];
		else
			return null;
	}
	
	public static SemanaAgregada loadSemanaAgregadaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) {
		SemanaAgregada[] semanaAgregadas = listSemanaAgregadaByQuery(session, condition, orderBy, lockMode);
		if (semanaAgregadas != null && semanaAgregadas.length > 0)
			return semanaAgregadas[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateSemanaAgregadaByQuery(String condition, String orderBy) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return iterateSemanaAgregadaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static java.util.Iterator iterateSemanaAgregadaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) {
		try {
			PersistentSession session = smartgrid.SmartgridPersistentManager.instance().getSession();
			return iterateSemanaAgregadaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static java.util.Iterator iterateSemanaAgregadaByQuery(PersistentSession session, String condition, String orderBy) {
		StringBuffer sb = new StringBuffer("From smartgrid.SemanaAgregada as SemanaAgregada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static java.util.Iterator iterateSemanaAgregadaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) {
		StringBuffer sb = new StringBuffer("From smartgrid.SemanaAgregada as SemanaAgregada");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			return null;
		}
	}
	
	public static SemanaAgregada loadSemanaAgregadaByCriteria(SemanaAgregadaCriteria semanaAgregadaCriteria) {
		SemanaAgregada[] semanaAgregadas = listSemanaAgregadaByCriteria(semanaAgregadaCriteria);
		if(semanaAgregadas == null || semanaAgregadas.length == 0) {
			return null;
		}
		return semanaAgregadas[0];
	}
	
	public static SemanaAgregada[] listSemanaAgregadaByCriteria(SemanaAgregadaCriteria semanaAgregadaCriteria) {
		return semanaAgregadaCriteria.listSemanaAgregada();
	}
	
	public static SemanaAgregada createSemanaAgregada() {
		return new smartgrid.SemanaAgregada();
	}
	
	public boolean save() {
		try {
			smartgrid.SmartgridPersistentManager.instance().saveObject(this);
			return true;
		}
		catch (Exception e) {
			return false;
		}
	}
	
	public boolean delete() {
		try {
			smartgrid.SmartgridPersistentManager.instance().deleteObject(this);
			return true;
		}
		catch (Exception e) {
			return false;
		}
	}
	
	public boolean refresh() {
		try {
			smartgrid.SmartgridPersistentManager.instance().getSession().refresh(this);
			return true;
		}
		catch (Exception e) {
			return false;
		}
	}
	
	public boolean evict() {
		try {
			smartgrid.SmartgridPersistentManager.instance().getSession().evict(this);
			return true;
		}
		catch (Exception e) {
			return false;
		}
	}
	
	public boolean deleteAndDissociate() {
		try {
			if(getContract() != null) {
				getContract().semanaAgregadas.remove(this);
			}
			
			return delete();
		}
		catch(Exception e) {
			return false;
		}
	}
	
	public boolean deleteAndDissociate(org.orm.PersistentSession session) {
		try {
			if(getContract() != null) {
				getContract().semanaAgregadas.remove(this);
			}
			
			try {
				session.delete(this);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			return false;
		}
	}
	
	private void this_setOwner(Object owner, int key) {
		if (key == smartgrid.ORMConstants.KEY_SEMANAAGREGADA_CONTRACT) {
			this.contract = (smartgrid.Contract) owner;
		}
	}
	
	org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
		public void setOwner(Object owner, int key) {
			this_setOwner(owner, key);
		}
		
	};
	
	private int ID;
	
	private smartgrid.Contract contract;
	
	private double domingoPrecoSUM;
	
	private double domingoPrecoAVG;
	
	private double segundaPrecoSUM;
	
	private double segundaPrecoAVG;
	
	private double tercaPrecoSUM;
	
	private double tercaPrecoAVG;
	
	private double quartaPrecoSUM;
	
	private double quartaPrecoAVG;
	
	private double quintaPrecoSUM;
	
	private double quintaPrecoAVG;
	
	private double sextaPrecoSUM;
	
	private double sextaPrecoAVG;
	
	private double sabadoPrecoSUM;
	
	private double sabadoPrecoAVG;
	
	private java.util.Date data;
	
	private String unidade;
	
	private double domingoGastoSUM;
	
	private double domingoGastoAVG;
	
	private double segundaGastoSUM;
	
	private double segundaGastoAVG;
	
	private double tercaGastoSUM;
	
	private double tercaGastoAVG;
	
	private double quartaGastoSUM;
	
	private double quartaGastoAVG;
	
	private double quintaGastoSUM;
	
	private double quintaGastoAVG;
	
	private double sextaGastoSUM;
	
	private double sextaGastoAVG;
	
	private double sabadoGastoSUM;
	
	private double sabadoGastoAVG;
	
	private void setID(int value) {
		this.ID = value;
	}
	
	public int getID() {
		return ID;
	}
	
	public int getORMID() {
		return getID();
	}
	
	public void setDomingoPrecoSUM(double value) {
		this.domingoPrecoSUM = value;
	}
	
	public double getDomingoPrecoSUM() {
		return domingoPrecoSUM;
	}
	
	public void setDomingoPrecoAVG(double value) {
		this.domingoPrecoAVG = value;
	}
	
	public double getDomingoPrecoAVG() {
		return domingoPrecoAVG;
	}
	
	public void setSegundaPrecoSUM(double value) {
		this.segundaPrecoSUM = value;
	}
	
	public double getSegundaPrecoSUM() {
		return segundaPrecoSUM;
	}
	
	public void setSegundaPrecoAVG(double value) {
		this.segundaPrecoAVG = value;
	}
	
	public double getSegundaPrecoAVG() {
		return segundaPrecoAVG;
	}
	
	public void setTercaPrecoSUM(double value) {
		this.tercaPrecoSUM = value;
	}
	
	public double getTercaPrecoSUM() {
		return tercaPrecoSUM;
	}
	
	public void setTercaPrecoAVG(double value) {
		this.tercaPrecoAVG = value;
	}
	
	public double getTercaPrecoAVG() {
		return tercaPrecoAVG;
	}
	
	public void setQuartaPrecoSUM(double value) {
		this.quartaPrecoSUM = value;
	}
	
	public double getQuartaPrecoSUM() {
		return quartaPrecoSUM;
	}
	
	public void setQuartaPrecoAVG(double value) {
		this.quartaPrecoAVG = value;
	}
	
	public double getQuartaPrecoAVG() {
		return quartaPrecoAVG;
	}
	
	public void setQuintaPrecoSUM(double value) {
		this.quintaPrecoSUM = value;
	}
	
	public double getQuintaPrecoSUM() {
		return quintaPrecoSUM;
	}
	
	public void setQuintaPrecoAVG(double value) {
		this.quintaPrecoAVG = value;
	}
	
	public double getQuintaPrecoAVG() {
		return quintaPrecoAVG;
	}
	
	public void setSextaPrecoSUM(double value) {
		this.sextaPrecoSUM = value;
	}
	
	public double getSextaPrecoSUM() {
		return sextaPrecoSUM;
	}
	
	public void setSextaPrecoAVG(double value) {
		this.sextaPrecoAVG = value;
	}
	
	public double getSextaPrecoAVG() {
		return sextaPrecoAVG;
	}
	
	public void setSabadoPrecoSUM(double value) {
		this.sabadoPrecoSUM = value;
	}
	
	public double getSabadoPrecoSUM() {
		return sabadoPrecoSUM;
	}
	
	public void setSabadoPrecoAVG(double value) {
		this.sabadoPrecoAVG = value;
	}
	
	public double getSabadoPrecoAVG() {
		return sabadoPrecoAVG;
	}
	
	public void setData(java.util.Date value) {
		this.data = value;
	}
	
	public java.util.Date getData() {
		return data;
	}
	
	public void setUnidade(String value) {
		this.unidade = value;
	}
	
	public String getUnidade() {
		return unidade;
	}
	
	public void setDomingoGastoSUM(double value) {
		this.domingoGastoSUM = value;
	}
	
	public double getDomingoGastoSUM() {
		return domingoGastoSUM;
	}
	
	public void setDomingoGastoAVG(double value) {
		this.domingoGastoAVG = value;
	}
	
	public double getDomingoGastoAVG() {
		return domingoGastoAVG;
	}
	
	public void setSegundaGastoSUM(double value) {
		this.segundaGastoSUM = value;
	}
	
	public double getSegundaGastoSUM() {
		return segundaGastoSUM;
	}
	
	public void setSegundaGastoAVG(double value) {
		this.segundaGastoAVG = value;
	}
	
	public double getSegundaGastoAVG() {
		return segundaGastoAVG;
	}
	
	public void setTercaGastoSUM(double value) {
		this.tercaGastoSUM = value;
	}
	
	public double getTercaGastoSUM() {
		return tercaGastoSUM;
	}
	
	public void setTercaGastoAVG(double value) {
		this.tercaGastoAVG = value;
	}
	
	public double getTercaGastoAVG() {
		return tercaGastoAVG;
	}
	
	public void setQuartaGastoSUM(double value) {
		this.quartaGastoSUM = value;
	}
	
	public double getQuartaGastoSUM() {
		return quartaGastoSUM;
	}
	
	public void setQuartaGastoAVG(double value) {
		this.quartaGastoAVG = value;
	}
	
	public double getQuartaGastoAVG() {
		return quartaGastoAVG;
	}
	
	public void setQuintaGastoSUM(double value) {
		this.quintaGastoSUM = value;
	}
	
	public double getQuintaGastoSUM() {
		return quintaGastoSUM;
	}
	
	public void setQuintaGastoAVG(double value) {
		this.quintaGastoAVG = value;
	}
	
	public double getQuintaGastoAVG() {
		return quintaGastoAVG;
	}
	
	public void setSextaGastoSUM(double value) {
		this.sextaGastoSUM = value;
	}
	
	public double getSextaGastoSUM() {
		return sextaGastoSUM;
	}
	
	public void setSextaGastoAVG(double value) {
		this.sextaGastoAVG = value;
	}
	
	public double getSextaGastoAVG() {
		return sextaGastoAVG;
	}
	
	public void setSabadoGastoSUM(double value) {
		this.sabadoGastoSUM = value;
	}
	
	public double getSabadoGastoSUM() {
		return sabadoGastoSUM;
	}
	
	public void setSabadoGastoAVG(double value) {
		this.sabadoGastoAVG = value;
	}
	
	public double getSabadoGastoAVG() {
		return sabadoGastoAVG;
	}
	
	public void setContract(smartgrid.Contract value) {
		if (contract != null) {
			contract.semanaAgregadas.remove(this);
		}
		if (value != null) {
			value.semanaAgregadas.add(this);
		}
	}
	
	public smartgrid.Contract getContract() {
		return contract;
	}
	
	/**
	 * This method is for internal use only.
	 */
	private void setORM_Contract(smartgrid.Contract value) {
		this.contract = value;
	}
	
	private smartgrid.Contract getORM_Contract() {
		return contract;
	}
	
	public String toString() {
		return String.valueOf(getID());
	}
	
}
